#include <iostream>
#include <vector>

using std::vector;
using std::cin;
using std::cout;
using std::endl;

int main(int argc, char const *argv[])
{
    int n; // 数组元素个数
    cin >> n;

    vector<int> v1(n,0);
    vector<int> v2(v1);

    for(int i = 0;i < n;++ i)
    {
        cin >> v1[i];
        if(i == 0) v2[i] = v1[i];
        else v2[i] = v1[i] + v2[i - 1];
    }

    int left,right;
    while(cin >> left >> right)
    {
        int rst;
        if(left == 0) rst = v2[right];
        else rst = v2[right] - v2[left - 1];
        cout << rst << endl;
    }
    return 0;
}
